package  com.chint.largeData;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import cn.jpush.android.api.JPushInterface;

import com.chint.largeData.tools.SharePreferencesUtil;
import com.chint.largeData.tools.StringTools;

public class StartPage extends Activity {
    private ImageView imageView;
    private boolean tiao = true;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.inde);
        init();
    }

    public void init() {
        imageView = (ImageView) this.findViewById(R.id.imageView1);
       
        Animation amint = AnimationUtils.loadAnimation(this, R.anim.fasein);
        amint.setAnimationListener(new MyAnimationListener());
        imageView.startAnimation(amint);
    }
    class MyAnimationListener implements AnimationListener {

        @Override
        public void onAnimationEnd(Animation animation) {
            if (tiao) {
                String pageView = SharePreferencesUtil.getInstance(StartPage.this).getValue(SharePreferencesUtil.PAGEVIEW,"");
                if (pageView.equals("1") || !StringTools.isEmpty(pageView)) {
                    Intent intent = new Intent();
                    intent.setClass(StartPage.this, PageView.class);
                    StartPage.this.startActivity(intent);
                    SharePreferencesUtil.getInstance(StartPage.this).setValue(SharePreferencesUtil.PAGEVIEW,"2");
                } else {
                    Intent intent = new Intent();
                    intent.setClass(StartPage.this, HomePage.class);
                    startActivity(intent);

                }
            }
            StartPage.this.finish();
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onAnimationStart(Animation animation) {
            // TODO Auto-generated method stub

        }

    }

    @Override
   	protected void onResume() {
   		super.onResume();
   		JPushInterface.onResume(this);
   	}


   	@Override
   	protected void onPause() {
   		super.onPause();
   		JPushInterface.onPause(this);
   	}
}
